package com.LeeCode;

/**
 * 移除元素
 */

public class Code027 {
    public static void main(String[] args) {
        int[] nums = {3,2,2,3};
        System.out.println(new Code027().removeElement(nums, 2));

    }

    public int removeElement(int[] nums, int val) {
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) {
                nums[index] = nums[i];
                index++;
            }
        }

        return index;
    }
}
